package com.cj.config;

import com.cj.filter.TestFilter1;
import com.cj.filter.TestFilter2;
import org.springframework.boot.web.servlet.FilterRegistrationBean;

/**
 * 如果不用@WebFilter注解，则需要此过滤器配置来实例化Filter类
 */
//@Configuration
public class FilterConfig {

    //@Bean
    public FilterRegistrationBean registFilter1() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new TestFilter1());//设置过滤器
        registration.addUrlPatterns("/*");//设置过滤URL
        registration.setName("TestFilter1");//设置过滤器名称
        registration.setOrder(1);//设置过滤器执行顺序
        return registration;
    }

    //@Bean
    public FilterRegistrationBean registFilter2() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new TestFilter2());
        registration.addUrlPatterns("/*");
        registration.setName("TestFilter2");
        registration.setOrder(2);
        return registration;
    }


}
